package com.lsh.airticket.service.impl;

import com.github.pagehelper.PageInfo;
import com.lsh.airticket.dao.AirportDao;
import com.lsh.airticket.entity.Airport;
import com.lsh.airticket.service.AirportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 * @author lsh
 * @date 2021/2/17
 **/
@Service
public class AirportServiceImpl implements AirportService {

    @Autowired
    AirportDao airportDao;

    @Override
    public PageInfo<Airport> findAirport() {
        List<Airport> tbAirportAll = airportDao.findTbAirportAll();
        PageInfo<Airport> pageInfo = new PageInfo<>(tbAirportAll);
        return pageInfo;
    }

    @Override
    public int insertAirport(Airport airport) {
        airport.setAirportCreatetime(new Date());
        return airportDao.insertTbAirport(airport);
    }

    @Override
    public PageInfo<Airport> finAirportByCityId(Integer cityId) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("cityId", cityId);
        List<Airport> tbAirportByCondition = airportDao.findTbAirportByCondition(map);
        PageInfo<Airport> pageInfo = new PageInfo<>(tbAirportByCondition);
        return pageInfo;
    }

    @Override
    public int deleteAirportById(Integer airportId) {
        return airportDao.deleteTbAirportById(airportId);
    }


}
